package com.art.sunflower.mapper;

import com.art.sunflower.pojo.News;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface NewsMapper {
    @Select("select * from news where id = #{id}")
    Map<String, String> selectById(int id);

    @Insert("insert into news(url,title,info,date,author,content) values (#{url},#{title},#{info},#{date},#{author},#{content})")
    int addNews(News news);

    @Delete("delete from news where id = #{id}")
    int deleteById(int id);

    @Update("update news set url=#{url},title=#{title},info=#{info},author=#{author},content=#{content} where id=#{id}")
    int updateNewsById(News news);

    @Select("select * from news")
    List<Map<String, Object>> findAllNews();
}
